from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from .views import statistical,users,skus,orders,specs,permissions,groups,admin

urlpatterns = [
    # JWT登录
    url(r'^authorizations/$', obtain_jwt_token),

    # ----------------数据统计-------------------
    # 用户总数统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 当天注册用户总数统计
    url(r'^statistical/day_increment/$',statistical.UserDayCountView.as_view()),
    # 当天登录用户总数统计
    url(r'^statistical/day_active/$',statistical.UserActiveCountView.as_view()),
    # 当天下单用户总数统计
    url(r'^statistical/day_orders/$',statistical.UserOrderCountView.as_view()),
    # 一个月范围的注册用户总数统计
    url(r'^statistical/month_increment/$',statistical.UserMonthCountView.as_view()),
    # 商品分类访问量统计
    url(r'^statistical/goods_day_views/$',statistical.GoodsTypeCountView.as_view()),

    # -----------------用户数据操作-------------------
    url(r'^users/$', users.UserView.as_view()),

    # ----------------spu商品列表获取------------------
    url(r'^goods/simple/$',specs.SpecsView.as_view({'get':'simple'})),

    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),

    # 获取权限分类
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_types'})),

    # 获取权限分类
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),

    # 获取分组信息
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),
]

# ----------- 商品规格表路由匹配----------------------
router = DefaultRouter()
router.register('goods/specs',specs.SpecsView,base_name='spec')
urlpatterns += router.urls

# ----------- 商品SKU表路由匹配----------------------
router = DefaultRouter()
router.register('skus',skus.SKUView,base_name='skus')
urlpatterns += router.urls

# ------- 订单表路由匹配-----------
router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# ------- 权限表路由匹配-----------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, base_name='perms')
urlpatterns += router.urls

# ------- 分组表路由匹配-----------
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# ------- 管理员路由匹配-----------
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, base_name='admins')
urlpatterns += router.urls